<?php

class Factory {

    public static function fillArrayWithObjects($array, $objectName) {
        $tmp = array();
        for ($index = 0; $index < count($array[0][$objectName]); $index++) {
            $constructor = ucfirst($objectName);
            switch ($constructor) {
                case 'Artist':
                    array_push($tmp, new Artist($array[0][$objectName][$index]));
                    break;

                case 'Genre':
                    array_push($tmp, new Genre($array[0][$objectName][$index]));
                    break;

                case 'Style':
                    array_push($tmp, new Style($array[0][$objectName][$index]));
                    break;

                case 'Track':
                    array_push($tmp, new Track($array[0][$objectName][$index]));
                    break;

                case 'Format':
                    array_push($tmp, new Format($array[0][$objectName][$index]));
                    break;

                case 'Image':
                    array_push($tmp, new Image($array[0][$objectName][$index]['__attributes__']));
                    break;
                
                default:
                    break;
            }
        }
        return $tmp;
    }
    
}

?>
